﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Structura.Silverlight.Infrastructure.Commanding;
using MusicStore.Silverlight.ViewModels;

namespace MusicStore.Silverlight.Commands
{
    public class SearchCommand : BaseCommand
    {
        public SearchCommand(ISearchViewModel viewModel)
        {
            _viewModel = viewModel;
        }

        private ISearchViewModel _viewModel;

        // todo: castle windsor bug, this should be private
        //public ISearchViewModel _viewModel { get; set; }

        protected override bool CanExecuteImpl(object parameter)
        {
            return !_viewModel.IsBusy;
        }

        public override void Execute(object parameter)
        {
            _viewModel.PerformSearch(parameter.ToString());
        }
    }
}
